home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vbinst13
/
vbinst.frm
< prev
next >
Wrap
Text File
|
1995-12-05
|
16KB
|
481 lines
VERSION 2.00
Begin Form Install
BackColor = &H00C0C0C0&
Caption = "Install"
ClientHeight = 2745
ClientLeft = 1245
ClientTop = 2880
ClientWidth = 7245
Height = 3150
Icon = VBINST.FRX:0000
Left = 1185
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 2745
ScaleWidth = 7245
Top = 2535
Width = 7365
Begin DirListBox Dir1
Height = 315
Left = 2175
TabIndex = 3
Top = 2325
Visible = 0 'False
Width = 915
End
Begin CommandButton Cmd_Start
Caption = "&Start"
Default = -1 'True
Height = 540
Left = 6150
TabIndex = 8
Top = 2025
Width = 990
End
Begin CheckBox Check1
BackColor = &H00C0C0C0&
Caption = "&OK to create?"
ForeColor = &H00000000&
Height = 390
Left = 150
TabIndex = 10
Top = 2025
Width = 1890
End
Begin CommandButton Cmd_Cancel
Cancel = -1 'True
Caption = "&Cancel"
Height = 540
Left = 6150
TabIndex = 7
Top = 1350
Width = 990
End
Begin ListBox List1
BackColor = &H00C0C0C0&
ForeColor = &H00000000&
Height = 1005
Left = 2250
TabIndex = 4
Top = 1275
Width = 3090
End
Begin Frame Fr_Dest
Caption = "D&estination SubDirectory"
Height = 660
Left = 3525
TabIndex = 6
Top = 75
Width = 3015
Begin TextBox Txt_Dest
ForeColor = &H00000000&
Height = 315
Left = 75
TabIndex = 0
Top = 300
Width = 2865
End
End
Begin Frame Fr_Drive
BackColor = &H00C0C0C0&
Caption = "&Destination Disk"
Height = 660
Left = 675
TabIndex = 1
Top = 75
Width = 2760
Begin DriveListBox Drive1
ForeColor = &H00000000&
Height = 315
Left = 75
TabIndex = 2
Top = 300
Width = 2295
End
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "Do you want install to create own Program Manager Group?"
ForeColor = &H00000000&
Height = 615
Left = 150
LinkTimeout = 10
TabIndex = 9
Top = 1350
Width = 1890
End
Begin Label Lbl_List
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Height = 315
Left = 1500
TabIndex = 5
Top = 900
Visible = 0 'False
Width = 4515
End
End
Function CheckDir (Chk As Integer) As Integer
'**********************************************************************
'* Check destination directory, that it does not exceed allowed *
'* 11 characters (8+3).If user gives directory such as "..\myprogram",*
'* which has 9 characters in body part, Visual Basic does not *
'* generate an error code. VB just cut chrs exceeding 8 limit from *
'* left. So "..\myprogram " would be "..\myprogra", but in Program *
'* Manager Group item path is still "..\myprogram ", which would cause*
'* error runing the istalled program. *
'* To find first "\" (backslash) from right, *
'* we need to examine destination path string in reverse order *
'* For example "D:\WINDOWS\VBINST" would be "TSNIBV\SWODNIW\:D". *
'* Now we can use InStr function to find first occurence of "\" *
'* in destination path and check the destination directory. *
'**********************************************************************
DirLen% = Len(Txt_Dest.Text)
For J% = DirLen% To 1 Step -1
Temp$ = Mid$(Txt_Dest.Text, J%, 1)
Directory$ = Directory$ + Temp$
Next
'Get destination SubDirectory string
'Get directory's extension if exist
'Get directory's bodypart
Directory$ = Left$(Directory$, (InStr(Directory$, "\")))
Extension% = InStr(Directory$, ".")
BodyPart% = InStr(Directory$, "\") - Extension%
'Check extension to not exceed 3 chrs
If (Extension% = 0 Or Extension% < 5) Then
'if not extension exceed 3, check bodypart to not exceed 8 chrs
If BodyPart% > 9 Then
Chk = 0
Else
Chk = 2
End If
Else
Chk = 1
End If
End Function
Sub Cmd_Cancel_Click ()
Const IDYES = 6 'define msgbox return value
If Cmd_Cancel.Caption = "&Cancel" Then
Msg$ = "Are you sure you want to cancel install?" 'give the user a second change
Title$ = "CANCEL???"
Response% = MsgBox(Msg$, 292, Title$) ' Get user response. '36+4+256
If Response% = IDYES Then ' Evaluate response
End
Else
Exit Sub
End If
Else
End
End If
End Sub
Sub Cmd_Start_Click ()
Dim ErrDirTitle As String
ErrDirTitle$ = "Error creating SubDirectory"
'Set Flag for checking files overwritφng
WarnFlag = True
'assign drive to DestDrive variable for checking needed free diskspace
DestDrive$ = Left$(LCase$(Txt_Dest.Text), 1)
'see Function NeedSpace in general section
RetValue% = NeedSpace(Chk%)
If Chk% = False Then Exit Sub 'not enough diskspace
'Check destination directory's number of characters.
'See Function CheckDir in general procedure
RetValue% = CheckDir(Chk%)
If Chk% = 0 Then
Msg$ = "Directory's bodypart exceeded 8 characters"
MsgBox Msg$, 16, ErrDirTitle$
Txt_Dest.Text = LCase$(LoadDir$) 'change back to default dir drive
Exit Sub
ElseIf Chk% = 1 Then
Msg$ = "Directory's extension exceeded 3 characters"
MsgBox Msg$, 16, ErrDirTitle$
Txt_Dest.Text = LCase$(LoadDir$) 'change back to default dir drive
Exit Sub
End If
On Error Resume Next 'Set up error handling.
DestDir$ = LCase$(Txt_Dest.Text) 'Make path specification.
twobs% = InStr(DestDir$, "\\") 'check if user has put accidently two backslash
If twobs% <> 0 Then 'into subdirectory's name
Msg$ = "SubDirectory has 2 (\\) backslash! "
MsgBox Msg$, 16, ErrDirTitle$
Txt_Dest.Text = LCase$(LoadDir$) 'change back to default dir drive
Drive1.Drive = Left$(WD$, 1)
Exit Sub
Else
ChDir DestDir$ 'check if directory already exist
If Err = 76 Or Err = 0 Then 'see error values
Err = 0 'reset err
MkDir DestDir$ 'make directory
If Err = 76 Then 'wrong directory name
Msg$ = "Could not create such SubDirectory!, Check the SubDirectory's name."
MsgBox Msg$, 16, ErrDirTitle$
Txt_Dest.Text = LCase$(LoadDir$) 'change back to default dir drive
Drive1.Drive = Left$(WD$, 1)
Exit Sub
End If
End If
End If
'change back to source directory
ChDir SD$
'start installing job
Install.Refresh
Lbl_List.Visible = True
List1.Refresh
Lbl_List.Refresh
'get files from install.inf using GetPrivateProfileString API call
'to be copied windows system dir
lpApplication$ = "SystemFiles"
lpDefault$ = "EndMark"
lpKeyName$ = "file"
SubDir$ = WSD$
IniCopy lpApplication$, lpKeyName$, lpDefault$, SubDir$
'get files from install.inf using